var app = getApp();

Page({
  data: {},
  onLoad: function (options) {
    var that = this;
    var title = '';
    that.setData({
      userId: options.userId
    });
    if (options.userId == wx.getStorageSync("userId")) {
      title = '我的信誉'
    } else {
      title = '用户信息'
    }
    wx.setNavigationBarTitle({
      title: title
    });
    that.getData();
  },
  getData: function () {
    var that = this;
    app.JsonPost("Api/User/index", {
      user_id: that.data.userId
    }, function (res) {
      //console.log(res);
      var certification = '';
      if (res.mobile == null || res.identity == null || res.real_name == '') {
        certification = "未实名认证";
      } else {
        certification = "已实名认证";
      }
      that.setData({
        userName: res.user_name,
        avatar: res.avatar,
        certification: certification,
        credit: res.credit,
        level_label: res.level_label,
        tripCount: res.statistics.tripCount,
        successOrderCount: res.statistics.successOrderCount,
        failOrderCount: res.statistics.failOrderCount,
        canceledOrderCount: res.statistics.canceledOrderCount
      })
    });
  }
})